<?php
require_once '../../Lib/main.php';
$id = null;
$name = null;
$orderIndex = null;
$deleteFLg = '1';
$id_category = null;
$folder = null;

if (isset($_REQUEST['id']) && trim($_REQUEST['id']) !== '') {
	$id = $_REQUEST['id'];
}

if (isset($_REQUEST['name']) && trim($_REQUEST['name']) !== '') {
	$name = $_REQUEST['name'];
}

if (isset($_REQUEST['orderIndex']) && trim($_REQUEST['orderIndex']) !== '') {
	$orderIndex = $_REQUEST['orderIndex'];
}

if (isset($_REQUEST['deleteFLg']) && trim($_REQUEST['deleteFLg']) !== '') {
	$deleteFLg = $_REQUEST['deleteFLg'];
}

if (isset($_REQUEST['folder']) && trim($_REQUEST['folder']) !== '') {
	$folder = $_REQUEST['folder'];
}

if (isset($_REQUEST['id_category']) && trim($_REQUEST['id_category']) !== '') {
	$id_category = $_REQUEST['id_category'];
}

$proClassDao = new  Dao_ProductClassDAO();
$proClass = new Model_ProductClass(array());
$proClass->setId($id);
$proClass->setNameClass($name);
$proClass->setOrderIndex($orderIndex);
$proClass->setDeleteFlg($deleteFLg);
//$proClass->setNameClassFolder($folder);
$proClass->setIdCategory($id_category);
$success = $proClassDao->insertOrUpdate($proClass);
if ($id === null) {
	$id = $proClassDao->getMaxId();
	$create_path = __DIR__ . "/../../". PICTURE_PROD_FOLDER. "/" . $id;
	//echo $create_path;
	mkdir($create_path, 0777);
}


$url = '';
if($success) {
	$url = getUrlAdmin("success.php", "rep=listproductclass.php");
} else {
	$url = getUrlAdmin("error.php", "rep=listproductclass.php");
}

//header('Location: ../'.$url);
?>
<script type="text/javascript" src="../js/custom.js"></script>
<script type="text/javascript">
 	goTo('../<?php echo $url;?>');
</script>